updater_mod = {
    baseId: '70641',
    baseUrl: 'http://userscripts.org/scripts/source/',
    bannedLetters: ['F','C'],
    html: '<div id="tplus_msgbox" class="overlay" style="position: fixed; z-index: 900001; top: 233px; left: 629px; opacity: 1;"> <div class="overlayBody"> <div class="feedBack alert"> <div class="feedBackContent"> <div class="feedBackBody"> <a title="Cerrar" id="tplus_msgbox_close" class="close" href="#"></a> <h2 class="title">Tuenti Plus!</h2> <div id="tplus_msgbox_msg"> </div> <div class="buttons"> <button id="tplus_msgbox_ok" class="big plane"> <span><span>Aceptar</span></span> </button> <a title="Cancelar" href="#" id="tplus_msgbox_cancel">Cancelar</a> </div> </div> </div> </div> </div></div>',
    msg: '<strong>Se ha encontrado una version nueva de Tuenti Plus!</strong><br/><div style="margin: 5px 0 10px 0">¿Desea actualizar ahora?</div>',
    init: function() {
        
        var version = system_lib.eapi.version;
        
        //Por si no dio tiempo al updateVersion inicial (PCs/Coneciones muy rapidos/as)
        if (!version) {
            setTimeout('updater_mod.init();',10000);
            return;
        }

        var word = system_lib.eapi.version.charAt(system_lib.eapi.version.length - 1);

        if (this.bannedLetters.indexOf(word) != -1) {
            return;
        }
        
        if (config_plus.neededVersion != system_lib.eapi.version) {
            this.showUpdateMsg();
        }
    },
    showUpdateMsg: function() {
        var overlay = document.getElementById('overlaysContainer');

        //establecemos el cuadro de dialogo
        overlay.innerHTML = this.html;

        //el mensaje de contenido
        var msg = document.getElementById('tplus_msgbox_msg');
        msg.innerHTML = this.msg;

        //asignamos eventos
        var bclose = document.getElementById('tplus_msgbox_close');
        bclose.addEventListener('click', this._onClickClose, false);

        var bcancel = document.getElementById('tplus_msgbox_cancel');
        bcancel.addEventListener('click', this._onClickClose, false);

        var bok = document.getElementById('tplus_msgbox_ok');
        bok.addEventListener('click', this._onClickOk, false);
    },
    _onClickClose: function(ev) {
        ev.preventDefault();
        autoUpdate.closeWindow();

    },
    _onClickOk: function(ev) {
        window.open(updater_mod.baseUrl + updater_mod.baseId + '.user.js');
        autoUpdate.closeWindow();
    },
    closeWindow: function () {
        var overlay = document.getElementById('overlaysContainer');
        var msgBox = document.getElementById('tplus_msgbox');

        overlay.removeChild(msgBox);
    }

};

updater_mod.init();
